package exercise.core;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class WebServer {
    private ServerSocket serverSocket;
    public WebServer(){
        try{
        System.out.println("zheng zai jianli ");
        serverSocket = new ServerSocket(8088);
        System.out.println("cheng gong jian li");
        }catch (IOException e){
            e.printStackTrace();
        }
    }
    public void start(){
        try {
            System.out.println("ke hu duan lian jie");
            Socket socket = serverSocket.accept();
            System.out.println("ke hu duan yi lian jie");
            ClientHandler handler = new ClientHandler(socket);
            Thread t = new Thread(handler);
            t.start();
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        WebServer webServer  =  new WebServer();
        webServer.start();
    }
}
